import time

from selenium import webdriver
import pytest,logging,json
from Page import Page
def du():
    with open('min.json','r',encoding='utf8')as f:
        return json.load(f)
datas=du()
@pytest.fixture()
def dr():
    dr=webdriver.Firefox()
    logging.debug('用例执行前执行')
    dr.maximize_window()
    yield dr
    logging.debug('用例执行后执行')
    dr.quit()
@pytest.mark.parametrize('data',datas)
def test_001(dr,data):
    try:
        a=Page(dr)
        logging.debug('用例执行时执行')
        a.cz(data['username'],data['password'])
    except Exception as e:
        print(e)
        t=time.strftime('%Y%m%d%H%M%S')
        dr.save_screenshot(t+".png")
